/*
 ------------------------------------------------------------------------------
 Copyright (C) 2013 Eternal Games.

 This file is part of the GLQuake source code.

 The GLQuake source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The GLQuake source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the GLQuake source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// cg_particle.cpp - particle definition parsing and loading
//


#include "cg_local.h"


#define PARTICLES_HASH_SIZE				(MAX_PARTICLES >> 2)

static particle_t			cg_parseParticle;

static particle_t *			cg_particlesHashTable[PARTICLES_HASH_SIZE];
static particle_t *			cg_particles[MAX_PARTICLES];
static int					cg_numParticles;


/*
 ==============================================================================

 PARTICLE PARSING

 ==============================================================================
*/


/*
 ==============================================================================

 PARTICLE LOADING

 ==============================================================================
*/


/*
 ==================
 
 ==================
*/
particle_t *CG_RegisterParticle (const char *name){

	return NULL;
}


/*
 ==============================================================================

 CONSOLE COMMANDS

 ==============================================================================
*/


/*
 ==================
 
 ==================
*/
void CG_ListParticles_f (){

}

/*
 ==================
 
 ==================
*/
void CG_ReloadParticle_f (){

}


/*
 ==============================================================================

 DEFAULT PARTICLES

 ==============================================================================
*/


/*
 ==================
 
 ==================
*/
void CG_CreateDefaultParticles (){

}


/*
 ==============================================================================

 INITIALIZATION & SHUTDOWN

 ==============================================================================
*/


/*
 ==================
 CG_InitParticles
 ==================
*/
void CG_InitParticles (){

	G_Printf("Initializing Particles\n");

	// Add commands
	glqCmdSystem->AddCommand("listParticles", CG_ListParticles_f, "Lists loaded particles", NULL);
	glqCmdSystem->AddCommand("reloadParticle", CG_ReloadParticle_f, "Reloads a particle", glqCmdSystem->ArgCompletion_ParticleName);

	// Create the default particles
	CG_CreateDefaultParticles();

	// Register the particle definition type
	glqDefManager->RegisterType(DEF_PARTICLE, "particle", "particles", ".part", "listParticleDefs", "printParticleDef");

	// Load all the particle definitions
	glqDefManager->LoadDefs(DEF_PARTICLE, true);
}

/*
 ==================
 CG_ShutdownParticles
 ==================
*/
void CG_ShutdownParticles (){

	// Remove commands
	glqCmdSystem->RemoveCommand("listParticles");
	glqCmdSystem->RemoveCommand("reloadParticle");

	// Purge all the particle definitions
	glqDefManager->PurgeDefs(DEF_PARTICLE);

	// Clear particle list
	glqMemory->Fill(cg_particlesHashTable, 0, sizeof(cg_particlesHashTable));
	glqMemory->Fill(cg_particles, 0, sizeof(cg_particles));

	cg_numParticles = 0;
}